package com.zhouxiaoge;

import org.apache.commons.beanutils.converters.AbstractConverter;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-03-29 16:31
 */

public class EnumConverter extends AbstractConverter {

    @Override
    protected String convertToString(Object value) throws Throwable {
        return ((Enum) value).name();
    }

    @Override
    protected Object convertToType(Class type, Object value) throws Throwable {
        return Enum.valueOf(type, value.toString());
    }

    @Override
    protected Class getDefaultType() {
        return null;
    }
}
